#pragma once

#include "State.h"
#include "Font.h"
#include "GameState.h"
#include "TextControl.h"
#include <vector>

// Specialization of the CState class for 
// the game options submenu state. This displays a menu in which
// the player can change keyboard configuration
class CKeyMenuState : public CState
{
public:
	CKeyMenuState(void);
	~CKeyMenuState(void);

	void getKeyPressed();
	void Draw();
	void EnterState();

	static CKeyMenuState* GetInstance(CStateManager* pManager, CRenderer* pRenderer, HDC hDC, HWND hWnd);

protected:
	CKeyMenuState(CStateManager* pManager, CRenderer* pRenderer, HDC hDC, HWND hWnd);

private:
	// The player went up or down in 
	// the menu
	void SelectionUp();
	void SelectionDown();

	// The player validated the current selection
	void SelectionChosen();

	// save keys
	void SaveKeys();

	// validate key - if there are no duplicates
	void Validate(int iCurrentModified, std::string sKey);

	// validate all keys - if there are all set
	int ValidateAll();

	// Cancel key Change
	void Cancel();

	// Undo all key changes
	void UndoChanges();

	// Change key
	void ChangeKeyEvent();

	// add an item to the menu list
	int AddItem(vector<CTextControl*> &vec, CTextControl* pTextControl);

	// set text to selected menu item
	void SetSelectedText(int iPos, std::string sText);

	//pointer to render device object
	CRenderer* m_pRenderer;		

	// Index of the current selected menu item
	int m_iCurrentSelection;

	// Index of the modified menu item
	int m_iCurrentModified;

	// menu item text just before modification
	std::string m_sPreviousItem;

	// key change event activity
	bool m_bKeyChange;

	// A pointer to the current active game (if any).
	CGameState* m_pCurrentGame;

	// initial menu items
	std::vector<std::string> m_vInitialItem;

	//vector of menu items
	vector<CTextControl*> m_vMenuItems;

	//vector of menu items labels
	vector<CTextControl*> m_vMenuLabels;
};